package com.luobo.config;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Anwen
 * @Date 2019-09-25 9:43
 * @Version 1.0
 * AOP切面输出请求日志    阜阳请求平台日志  金融机构请求平台
 */
@Aspect
@Configuration
public class LogAspect {


    /**
     * Around:
     * Before:
     * After:
     * AfterThrowing:
     */

    /**
     * Around:
     * Before:
     * After:
     * AfterReturning:
     */



    /**
     * 切入点
     */
    @Pointcut("execution( * com.luobo.yfh..*.*(..))")
    public void logPointCut() {
    }


    @Around("logPointCut()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("Around:");
        return pjp.proceed();
    }

    @Before("logPointCut()")
    public void doBefore(JoinPoint joinPoint){
        System.out.println("Before:");

    }

    @AfterReturning(returning = "ret", pointcut = "logPointCut()")
    public void doAfterReturning(Object ret){
        System.out.println("AfterReturning:" +ret);
    }



    @After("logPointCut()")
    public void doAfter(JoinPoint point){
        System.out.println("After:");
    }



    @AfterThrowing(pointcut = "logPointCut()",throwing = "e")
    public void doAfterThrowing(JoinPoint joinPoint, Exception e){
        System.out.println("AfterThrowing:");
    }



}